package interpeter;



import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;


public class ActivationRecord
{
	//Map<String, Double> values = new HashMap<>();
	private Map<String, Object> values;
	
	public ActivationRecord() {
		this.values = new HashMap<>();
	}

	public Map<String, Object> getValueMap() {
		return values;
	}

	
	@Override
	public String toString()
	{
		StringBuffer bf = new StringBuffer();
		for (Entry<String, Object> kv : values.entrySet()) {
			if (bf.length() > 0) bf.append("  ");
			bf.append(String.format("%s->%s %s",
					kv.getKey(),
					getTypeName(kv.getValue()),
					kv.getValue()));
	
		}
		return "{" + bf.toString() + "}";
	}
	
	private String getTypeName(Object t){
		String s;
		if (t instanceof Integer){
			s="int";
		}else if (t instanceof Integer[]){
			s="int[]";
		}else if (t instanceof String){
			s="string";
		}else if (t instanceof String[]){
			s="string[]";
		}else if (t instanceof Boolean){
				s="boolean";
		}else if (t instanceof Boolean[]){
				s="boolean[]";
		}else s = "?type?";
		return s;
	}
}
